class Solution:
    def isValid(self, s: str) -> bool:
        dictConfig = {'(': ')', '[': ']', '{': '}'}
        stack = []
        result = False
        for i in s:
            val = dictConfig.get(i, '0')
            if val != '0':
                stack.append(val)
            else:
                if len(stack) == 0:
                    result = False
                    break
                else:
                    pop = stack.pop()  # 左面的
                    if pop == i:
                        result = True
                    else:
                        result = False
                        break

        if len(stack) == 0:
            return result
        else:
            return False
